package com.shrcl.engineerprocess.domain.impl;

import com.google.common.base.Objects;
import com.shrcl.engineerprocess.domain.CertificationAgencyCode;
import com.shrcl.engineerprocess.domain.CertificationMaintainerByAgency;
import com.shrcl.engineerprocess.domain.CertificationMaintainerByAgencyDAO;
import com.shrcl.engineerprocess.domain.impl.CertificationMaintainerByAgencyImpl;
import edu.fudan.mylang.pf.BaseDAOService;
import edu.fudan.mylang.pf.IGenericQuery;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.domain.CertificationMaintainerByAgencyDAO")
public class CertificationMaintainerByAgencyDAOImpl extends BaseDAOService<CertificationMaintainerByAgency> implements CertificationMaintainerByAgencyDAO {
  public CertificationMaintainerByAgency findorInitMaitainerByAgency(final CertificationAgencyCode agency) {
    CertificationMaintainerByAgency _xblockexpression = null;
    {
      IGenericQuery<CertificationMaintainerByAgency> query=getObjectFactory().createGenericQuery(CertificationMaintainerByAgency.class,"select e from com.shrcl.engineerprocess.domain.impl.CertificationMaintainerByAgencyImpl as e   where ((e.agency) = (:agency)) and  e.active = 1      ").setParameter("agency",agency);
      CertificationMaintainerByAgency r = query.uniqueResult();
      boolean _equals = Objects.equal(r, null);
      if (_equals) {CertificationMaintainerByAgency certificationMaintainerByAgency=CertificationMaintainerByAgencyImpl.create(getObjectFactory());
        final Procedure1<CertificationMaintainerByAgency> _function = new Procedure1<CertificationMaintainerByAgency>() {
            public void apply(final CertificationMaintainerByAgency it) {
              it.setAgency(agency);
            }
          };
        CertificationMaintainerByAgency _doubleArrow = ObjectExtensions.<CertificationMaintainerByAgency>operator_doubleArrow(certificationMaintainerByAgency, _function);
        r = _doubleArrow;
      }
      _xblockexpression = (r);
    }
    return _xblockexpression;
  }
}
